<template>
  <div class="main">
    <div>
    </div>
    <div class="avatar">
      <!-- <el-avatar id="path" :size="60" src="../assets/logo.png"></el-avatar> -->
      <img
        id="path"
        src="../assets/logo.png"
      />
    </div>
    <div class="item">
      <el-input
        placeholder="请输入账号"
        v-model="account"
        clearable
        prefix-icon="el-icon-user"
      ></el-input>
    </div>
    <div class="item">
      <el-input
        placeholder="请输入密码"
        v-model="password"
        @keyup.enter.native="login"
        show-password
        prefix-icon="el-icon-lock"
      ></el-input>
    </div>
    <div class="item">
      <el-button
        type="primary"
        round
        @click="login"
      >登录</el-button>
    </div>
  </div>
</template>

<script>
const { ipcRenderer } = require('electron')
export default {
  name: 'Login',
  data () {
    return {
      account: '',
      password: ''
    }
  },
  mounted () {
    console.log(document.getElementById('path').src)
  },
  methods: {
    login () {
      if (this.account === 'admin' && this.password === 'admin') {
        sessionStorage.setItem('login', 'success')
        this.$router.push({ path: '/Home' })
      } else {
        this.$message.error('用户名或密码错误')
      }
    },
    // 点击最小化按钮调用的方法
    minimize () {
      ipcRenderer.send('minimize')
    },
    // 点击关闭按钮调用的方法
    close () {
      ipcRenderer.send('close')
    }
  }
}
</script>

<style scoped lang="stylus">
.main
  margin-left 30px
  margin-right 30px
.avatar
  margin-top 40px
  margin-bottom 40px
button
  width 100%
.item
  margin-top 20px
</style>
